import React, { useEffect, useState, useMemo, useCallback } from 'react'
import Child from './Child'

export default function UseMemoDemo() {
  const [count, setCount] = useState(0)

  // useEffect(() => {
  //   setCount(count => count + 1)
  // }, [])

  // const handleClickChild = useMemo(() => {
  //   return () => {
    
  //   }
  // }, [])
  const handleClickChild = useCallback(() => {
    
  }, [])

  const doubleCount = useMemo(() => {
    return count * 2
  }, [count])

  return (
    <>
      <div>UseMemoDemo</div>
      <div>{doubleCount}</div>
      <Child onClick={handleClickChild}></Child>
      <button onClick={() => setCount(count => count + 1)}>add</button>
    </>
  )
}
